luci-proto-wireguard: fix loading peer descriptions
authorJo-Philipp Wich <[email protected]>
Wed, 23 Nov 2022 12:15:07 +0000 (13:15 +0100)
committerJo-Philipp Wich <[email protected]>
Wed, 23 Nov 2022 12:20:42 +0000 (13:20 +0100)
Explicitly load `network` uci in wireguard rpcd backend as `ctx.foreach()`
does not implicitly load it.

Also remove leftover test setup information from the status page source.

Fixes: #6095
Fixes: 008fa18878 ("luci-proto-wireguard: rewrite rpcd handler in ucode")
Fixes: 6e6fce3eb4 ("luci-proto-wireguard: merge status page functionality")
Ref: https://github.com/jow-/ucode/pull/126
Signed-off-by: Jo-Philipp Wich <[email protected]>
protocols/luci-proto-wireguard/htdocs/luci-static/resources/view/wireguard/status.js
protocols/luci-proto-wireguard/root/usr/share/rpcd/ucode/luci.wireguard

index 3b7fa13b25122f740039f2fafde8fa2fe39bf520..4344c36739592abab9ca1430bcb08ccbb3ec1765 100644 (file)
@@ -30,43 +30,6 @@ function timestampToStr(timestamp) {
        return (new Date(timestamp * 1000)).toUTCString() + ' (' + ago + ')';
 }
 
-/*
-{
-       "jow": {
-               "public_key": "o4iLoC1pl8+vEUshV7eUyKrryo7cr0WJkjS/Dlixxy8=",
-               "name": "jow",
-               "fwmark": "off",
-               "listen_port": "51821",
-               "peers": [
-                       {
-                               "endpoint": "45.13.105.118:51821",
-                               "public_key": "672KLy/R4miKXdvw2unuf9jQzVEmNnqen5kF+zVjMX0=",
-                               "name": "m300",
-                               "latest_handshake": "1668680574",
-                               "persistent_keepalive": "off",
-                               "allowed_ips": [
-                                       "192.168.220.10/32"
-                               ],
-                               "transfer_tx": "308",
-                               "transfer_rx": "220"
-                       },
-                       {
-                               "endpoint": "171.22.3.161:51821",
-                               "public_key": "yblNj1s41F8m1MdXhxD2U+Aew6ZR6Miy8OcNK/fkAks=",
-                               "name": "ac2",
-                               "latest_handshake": "0",
-                               "persistent_keepalive": "off",
-                               "allowed_ips": [
-                                       "192.168.220.11/32"
-                               ],
-                               "transfer_tx": "2960",
-                               "transfer_rx": "0"
-                       }
-               ]
-       }
-}
-*/
-
 function handleInterfaceDetails(iface) {
        ui.showModal(_('Instance Details'), [
                ui.itemlist(E([]), [
index fc99919127b25ac17c3f0c21220b7b1bac046fbc..add810c8ae8e693c99601e5ed3fc7ce1dd09d8bb 100644 (file)
@@ -52,6 +52,8 @@ const methods = {
                        const wg_dump = popen("wg show all dump 2>/dev/null");
 
                        if (wg_dump) {
+                               uci.load("network");
+
                                for (let line = wg_dump.read('line'); length(line); line = wg_dump.read('line')) {
                                        const record = split(rtrim(line, '\n'), '\t');